#include <card.h>
#include <cardspot.h>
#include <cardengine.h>
#include <platform.h>
#include <assert.h>

#include "card.h"

Card::Card(Suit s, int r)
    : RenderObject(Type_Card, 120, 120, 120), data(s, r)
{
}

Card::Suit Card::suit() const
{
    return data.suit;
}

int Card::rank() const
{
    return data.rank;
}

const std::string &Card::customData() const
{
    return data.customData;
}

void Card::setCustomData(const std::string &str)
{
    data.customData = str;
}

void Card::clearCustomData()
{
    data.customData.clear();
}

void Card::setCardSpot(CardSpot *spot)
{
    data.cardSpot = spot;
}

CardSpot * Card::cardSpot() const
{
    return data.cardSpot;
}

bool Card::isCovered() const
{
    return data.cardSpot && data.cardSpot->indexOf(this) < int(data.cardSpot->cards().size()) - 1;
    // ### not implicitly shared. inefficient to get list when all I want is size
}

Card::Face Card::face() const
{
    return data.face;
}

void Card::setFace(Face face)
{
    if (face != data.face) {
        data.face = face;
        update();
    }

}
